package com.edu.buservice.biz.covert;

import cn.hutool.core.date.DateUtil;
import com.edu.buservice.biz.model.Request.TenantRequest;
import com.edu.buservice.biz.model.Response.LabelTenantResponse;
import com.edu.buservice.biz.model.dto.TenantInfoDTO;
import com.edu.buservice.dal.model.SysTenant;

/**
 * @program: KQAIA
 * @description:
 * @author: 无恙
 * @create: 2025-03-09 14:38
 **/


public class TenantCovert {
	public static TenantInfoDTO convert(SysTenant sysTenant) {
		TenantInfoDTO tenantInfoDTO = new TenantInfoDTO();
		tenantInfoDTO.setId(sysTenant.getId());
		tenantInfoDTO.setTenantId(sysTenant.getTenantId());
		tenantInfoDTO.setName(sysTenant.getName());
		tenantInfoDTO.setStatus(sysTenant.getStatus());
		tenantInfoDTO.setCoastalToken(String.valueOf(sysTenant.getToken()));
		tenantInfoDTO.setCreateAt(DateUtil.format(sysTenant.getCreatedAt(), "yyyy-MM-dd"));
		return tenantInfoDTO;
	}


	public static LabelTenantResponse convert(TenantInfoDTO tenantInfoDTO) {
		LabelTenantResponse labelTenantResponse = new LabelTenantResponse();
		labelTenantResponse.setTenantId(tenantInfoDTO.getTenantId());
		labelTenantResponse.setTenantName(tenantInfoDTO.getName());
		return labelTenantResponse;
	}

	public static SysTenant convert(TenantRequest tenantRequest) {

		if (tenantRequest == null){
			return null;
		}

		SysTenant sysTenant = new SysTenant();
		sysTenant.setTenantId(tenantRequest.getTenantId());
		sysTenant.setName(tenantRequest.getTenantName());
		sysTenant.setStatus(tenantRequest.getStatus());
		return sysTenant;
	}
}
